Due: 5:00PM Friday, March 15, 2019 on OSF
Your team has been hired by NiceRide, Minneapolis’s Bicycle sharing service, to optimize their business. In their city, they have several docking stations that hold anywhere from 8-30 bicycles at a time. You can pick up a bicycle at one station, ride it somewhere, and leave it at another station. Every year, they log the data and post it on their website. You can get the data for 2017 here. Unzip the data and you will see three files: two datasets and one readme file.
The first dataset, Nice_Ride_2017_Station_Locations, contains information on the docking stations. There are about 200 stations, and they report the number of docks, latitude and longitude. The second dataset, Nice_ride_trip_history_2017_season, contains a log for all rides in 2017. Check out the readme file for a desciption on this dataset.
You will also need the following libraries. Lubridate helps us work with dates and times. OpenStreetMap is a package that allows us to plot maps. I have included the CRAN page for lubridate and tutorial on using OpenStreetMap for your reference:
# Load libraries
library(tidyverse)
library(lubridate)
library(OpenStreetMap)
For this datset, it would be really cool if we can make plots with an overlayed map. To do this, you will need to join the two datasets so that we can plot the Latitudes and Longitudes of the stations. Note that we need the latitude and longitude for both the starting and ending stations, which requires two different left-joins. Once you have done this, we can make really interesting plots with this data. Here is an example of a couple.
# Set latitudes and longitudes of city map
LAT1 <- 44.88
LAT2 <- 45.05
LON1 <- -93.35
LON2 <- -93.08
# Generate map
map <- openmap(c(LAT2,LON1), c(LAT1,LON2), zoom = NULL,
type = "esri",
mergeTiles = TRUE)
# Project map to latitude and longitude
map.latlon <- openproj(map, projection = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
# Plot map of Minneapolis
autoplot(map.latlon) # Plots a map
# Plot all niceride stations
autoplot(map.latlon) + # Plots a map
geom_point(data=locations,
aes(x=Longitude, y=Latitude),
color = 'blue', size = 1) +
labs(x='Longitude', y='Latitude') +
ggtitle('Locations of NiceRide Stations')
# Filter data for halloween morning
hallo <- data %>%
filter(Startingdate == "2017-08-31") %>%
filter(Startinghour < 8)
# Note that I used lubridate to make the columns Startingdate and Startinghour
# Plot rides for halloween morning
autoplot(map.latlon) + # Plots a map
geom_segment(data=hallo,
aes(x=start.long, y=start.lat,
xend=end.long, yend=end.lat),
color = 'blue', size = .5,
arrow = arrow(length = unit(0.2, "cm"))) +
labs(x='Longitude', y='Latitude') +
scale_x_continuous(limits = c(-93.3, -93.2)) +
scale_y_continuous(limits = c(44.93, 45.02)) +
ggtitle('Halloween Morning Rides')
There are a ton of different questions you can answer here. Each group member should choose a different question. Some good examples are:
Come up with your own interesting questions! There are alot of different things you can investigate!